--[[
MelonScript
Init
--]]

require( "datastream" )
require( "glon" )

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
AddCSLuaFile( "cl_nw.lua" )

include( 'shared.lua' )
include( 'sql.lua' )
include( 'configuration.lua' )
include( "pl_util.lua" )
include( 'chat.lua' )

function GM:PlayerLoadout( pl )
for k,v in pairs( melon.DefaultWeapons ) do
	pl:Give(v)
end
	pl:SelectWeapon("weapon_crowbar")
end

function GM:PlayerInitialSpawn( pl )
	self.BaseClass:PlayerInitialSpawn( pl )
if ( !pl:IndexExists("Name") ) then
	pl:SetNWString( "Name", "Unknown")
	pl:ConCommand("ccm_namemenu");
	pl:SetMoney( melon.Defaults.Money )
else
	pl:SetNWString( "Name", pl:GetPData("Name") )
	pl:SetNWInt( "Money", pl:GetMoney() ) -- This goes straight to PData
	pl:SetNWString( "Model", pl:GetPData("Model") )
end
end

function GM:PlayerSpawn( pl )
	self.BaseClass:PlayerSpawn( pl )
if ( !pl:IndexExists("Model") ) then
	pl:SetModel("models/player/Group01/male_04.mdl")
else
	pl:SetModel( pl:GetPData("Model") )
end
end

function GM:PlayerGiveSWEP( ply, class, wep )
	if ( ply:IsAdmin() or ply:IsSuperAdmin() ) then
		return true
	else
		return false
	end
end

-- Restrict spawning sweps.
function GM:PlayerSpawnSWEP( ply, class, wep )
	if ( ply:IsAdmin() or ply:IsSuperAdmin() ) then
		return true
	else
		return false
	end
end

-- Restrict Spawning vehicles.
function GM:PlayerSpawnVehicle( ply, mdl )
	if ( ply:IsAdmin() or ply:IsSuperAdmin() ) then
		return true
	else
		return false
	end
end